import request from '@/utils/request'
import requestSingle from '@/utils/requestSingle'
import { param } from 'jquery'
// 获取设备列表
export function getDeviceApi(pageNum, pageSize, groupId, meterModelId, keyword, meterType, orzId, sortType) {
    return request({
        url: '/mini/server/meter/page',
        method: 'get',
        params: {
            pageNum, pageSize, groupId, meterModelId, keyword, meterType, orzId, sortType
        }
    })
}
export function getDevice1Api(groupId, meterModelId, keyword, meterType, sortType) {
    return request({
        url: '/mini/server/meter',
        method: 'get',
        params: {
            groupId, meterModelId, keyword, meterType, sortType
        }
    })
}
//设置禁用禁用
export function postIsForbidApi(id, data) {
    return request({
        url: `/mini/server/meter/${id}/isForbid`,
        method: 'post',
        data
    })
}
//4G抵消
export function dedApi(id, data) {
    return request({
        url: `/mini/server/meter/${id}/minusOrder`,
        method: 'post',
        data
    })
}
//抵消记录
export function dedRecordApi(id, date, pageNum, pageSize) {
    return request({
        url: `/mini/server/meter/${id}/minusOrder`,
        params: {
            pageNum,
            pageSize,
            date
        }
    })
}
//抵消记录
export function caliRecordApi(id, date, pageNum, pageSize) {
    return request({
        url: `/mini/server/meter/${id}/changeUse`,
        params: {
            date,
            pageNum,
            pageSize
        }
    })
}
// 拉合闸
export function controlApi(id, data) {
    return request({
        url: `/mini/server/meter/fg/${id}/control`,
        method: 'post',
        data
    })
}
// 修改设备信息
export function editMeterApi(id, data) {
    return request({
        url: `/mini/server/meter/${id}`,
        method: 'put',
        data
    })
}
// 充值记录
export function getChargeRecordApi(id, pageNum, pageSize, rechargeTime, rechargeWay) {
    return request({
        url: `/mini/server/meter/${id}/pay/page`,
        params: { pageNum, pageSize, rechargeTime, rechargeWay }
    })
}
// 获取单一电表信息
export function getOneMeterApi(id) {
    return request({
        url: `/mini/server/meter/${id}`,
    })
}
// 获取充值方式
export function getChargeTypeApi() {
    return request({
        url: `/mini/server/user/payWay`,
    })
}
// 用电分析
export function getTimeAnalysisApi(id, date, dateOperation) {
    return request({
        url: `/mini/server/meter/${id}/quantity`,
        params: { date, dateOperation }
    })
}
// 设置单价
export function setPriceApi(data) {
    return request({
        url: `/mini/server/meter/singlePrice`,
        method: 'post',
        data
    })
}
// 设置单价
export function setMorePriceApi(data) {
    return request({
        url: `/mini/server/meter/batchPrice`,
        method: 'post',
        data
    })
}
// 获取抄表记录
export function getCopyRecordApi(meterId, pageNum, pageSize, readingTime) {
    return request({
        url: `/mini/server/meter/read/page`,
        params: { meterId, pageNum, pageSize, readingTime }
    })
}
//抄表
export function copyApi(id) {
    return request({
        url: `/mini/common/meter/fg/${id}/read`,
        method: 'post',
    })
}
// 解绑
export function delApi(id) {
    return request({
        url: `/mini/server/meter/${id}`,
        method: 'delete',
    })
}
// 获取分组
export function getGroupApi() {
    return request({
        url: `/mini/server/meter/group`,
    })
}
// 能耗分析
export function getQuantitiesApi(typeId, date, dateOperation) {
    return request({
        url: `/mini/server/meter/${typeId}/quantities`,
        params: { date, dateOperation }
    })
}
// 收入
export function getIncomeApi(date, dateOperation) {
    return request({
        url: `/mini/server/meter/income`,
        params: { date, dateOperation }
    })
}
// 收入排行
export function getIncomeRankApi(date, dateOperation) {
    return request({
        url: `/mini/server/meter/incomeRanking`,
        params: { date, dateOperation }
    })
}
// 管理员充值
export function payApi(id, data) {
    return request({
        url: `/mini/server/meter/${id}/pay/crash`,
        method: 'post',
        data,
    })
}
// 清零
export function clearApi(id) {
    return request({
        url: `/mini/server/meter/${id}/clear`,
        method: 'post',
    })
}
// 清零记录
export function clearRecordApi(clearTime, id, pageNum, pageSize) {
    return request({
        url: `/mini/server/meter/${id}/clear/page`,
        params: {
            clearTime,
            pageNum,
            pageSize
        }
    })
}
export function checkApi(id) {
    return request({
        url: `/mini/common/meter/${id}/checkPay`
    })
}
// 设备数量
export function getDeviceNumApi(groupId, meterType, orzId) {
    return request({
        url: `/mini/server/meter/amount`,
        params: { groupId, meterType, orzId }
    })
}
// 获取租币
export function getZubiApi(id) {
    return request({
        url: `/mini/common/meter/${id}/recharge/virtual`,
    })
}
// 获取租币
export function postZubiApi(id, data) {
    return request({
        url: `/mini/server/meter/${id}/recharge/virtual`,
        method: 'post',
        data
    })
}
// 修改区域
export function editOrzApi(data) {
    return request({
        url: `/mini/server/meter/orz`,
        method: 'put',
        data
    })
}
// 租币清零
export function clearZubiApi(id) {
    return request({
        url: `/mini/server/meter/${id}/recharge/virtual/clear`,
        method: 'post',
    })
}
// 充值报表
export function getChargeApi(pageNum, pageSize, startDate, endDate, meterId, meterName, meterNumber, meterAddress, orzId, meterType, rechargeWays,groupId) {
    console.log('请求参数', pageNum, pageSize, startDate, endDate, meterId, meterName, meterNumber, meterAddress, orzId, meterType,groupId);
    
    return request({
        url: `/mini/server/meter/pay/page`,
        params: { pageNum, pageSize, startDate, endDate, meterId, meterName, meterNumber, meterAddress, orzId, meterType, rechargeWays,groupId }
    })
}
// 能耗报表
export function getQuantitiesRecordApi(pageNum, pageSize, startDate, endDate, meterId, meterName, meterNumber, meterAddress, orzId, meterType,groupId) {
    return request({
        url: `/mini/server/meter/quantities/page`,
        params: { pageNum, pageSize, startDate, endDate, meterId, meterName, meterNumber, meterAddress, orzId, meterType,groupId }
    })
}
// 充值报表导出
export function chargeOutApi(pageNum, pageSize, startDate, endDate, meterId, meterName, meterNumber, meterAddress, orzId,rechargeWays,meterType) {
    return request({
        url: `/mini/server/meter/pay/export`,
        responseType: 'blob',
        params: { pageNum, pageSize, startDate, endDate, meterId, meterName, meterNumber, meterAddress, orzId,rechargeWays,meterType }
    })
}
// 能耗报表导出
export function quantitiesOutApi(pageNum, pageSize, startDate, endDate, meterId, meterName, meterNumber, meterAddress, orzId, meterType) {
    return request({
        url: `/mini/server/meter/quantities/export`,
        responseType: 'blob',
        params: { pageNum, pageSize, startDate, endDate, meterId, meterName, meterNumber, meterAddress, orzId, meterType }
    })
}
// 单一能耗分析报表导出
export function OneOutApi(date, dateOperation, id) {
    return request({
        url: `/mini/server/meter/${id}/quantity/export`,
        responseType: 'blob',
        params: { date, dateOperation }
    })
}
// 待充电订单充值
export function payAgainApi(id, data) {
    return request({
        url: `/mini/common/meter/fg/${id}/payAgain`,
        method: 'post',
        data
    })
}



// 设备管理导出
/* 
meterType 	设备类型(1:电表, 2:水表)
groupId     分组ID
meterModelId   模组型号ID
meterName    设备名称
orzId    区域Id
 */
// export function  deviceManagementExportApi(meterType,groupId,meterModelId,meterName,orzId) {
//     return request({
//         url: `/mini/server/meter/export`,
//         responseType: 'blob',
//         params: { meterType,groupId,meterModelId,meterName,orzId}
//     })
// }

export function deviceManagementExportApi(meterType, groupId, meterModelId, meterName, orzId) {
    return requestSingle({
        url: `/mini/server/meter/export`,
        responseType: 'blob',
        params: { meterType, groupId, meterModelId, meterName, orzId }
    })
}
// 
// 获取水表任务
export const getWaterApi = (meterId) => {
    return request({
        url: `/mini/server/meter/waterOffControl`,
        params: {
            meterId
        }
    })
}
// 获取水表清零任务
export const getWaterclearApi = (meterId) => {
    return request({
        url: `/mini/server/meter/waterOffClear`,
        params: {
            meterId
        }
    })
}
// 设置水表任务
export const setWaterApi = (data) => {
    return request({
        url: `/mini/server/meter/waterOffControl`,
        method: 'post',
        data
    })
}
// 设置水表清零任务
export const setWaterClearApi = (data) => {
    return request({
        url: `/mini/server/meter/waterOffClear`,
        method: 'post',
        data
    })
}
// 设置自定义排序   
export const setSortOrder = (id, data) => {
    return request({
        url: `/mini/server/meter/${id}/sort`,
        method: 'post',
        data
    })
}


// 批量--------------------------------
//电表- 拉合闸 - 支持的设备列表
export const getControlMultiDeviceList = (meterType, pageNum, pageSize,orzId,groupId) => {
    return request({
        url: `/mini/server/meter/fg/control/multiDeviceList`,
        params: {
            meterType, pageNum, pageSize,orzId,groupId
        }
    })
}

//电表- 设置拉合闸 -  control	false: 合闸, true:拉闸		f	deviceIds	设备id集合		array
export const setMeterControlMulti = (data) => {
    return request({
        url: `/mini/server/meter/fg/control/multi`,
        method: 'post',
        data
    })
}

//电表 -清零 -- 支持的设备列表
export const getMeterClearMultiDeviceList = (meterType, pageNum, pageSize,orzId,groupId) => {
    return request({
        url: `/mini/server/meter/clear/multiDeviceList`,
        params: {
            meterType,
            pageNum, pageSize,orzId,groupId
        }
    })
}

//   电表- 清零 - 批量操作deviceIds
export const setMeterClearMulti = (data) => {
    return request({
        url: `/mini/server/meter/clear/multi`,
        method: 'post',
        data
    })
}


// 水表-------------------------------------




// 批量--------------------------------
//水表- 拉合闸 - 支持的设备列表
export const getWaterOffMultiDeviceList = (meterType, pageNum, pageSize,orzId,groupId) => {
    return requestSingle({
        url: `/mini/server/meter/waterOffControl/multiDeviceList`,
        params: {
            meterType, pageNum, pageSize,orzId,groupId
        }
    })
}

//水表- 设置拉合闸 -  control	false: 合闸, true:拉闸		f	deviceIds	设备id集合		array
export const setWaterOffControl = (data) => {
    return requestSingle({
        url: `/mini/server/meter/waterOffControl/multi`,
        method: 'post',
        data
    })
}

//水表 -清零 -- 支持的设备列表
export const getwaterOffClearList = (meterType, pageNum, pageSize,orzId,groupId) => {
    return requestSingle({
        url: `/mini/server/meter/waterOffClear/multiDeviceList`,
        params: {
            meterType, pageNum, pageSize,orzId,groupId
        }
    })
}

//   水表- 清零 - 批量操作deviceIds
export const setWaterOffClear = (data) => {
    return requestSingle({
        url: `/mini/server/meter/waterOffClear/multi`,
        method: 'post',
        data
    })
}



// 批量充值支持的设备列表

export const getPayMultiDeviceList = (meterType, pageNum, pageSize,orzId,groupId) => {
    return requestSingle({
        url: `/mini/server/meter/pay/multiDeviceList`,
        params: {
            meterType,
            pageNum, pageSize,orzId,groupId
        }
    })
}


// 批量设置充值   deviceIds	设备id集合 money 
export const setPayMulti = (data) => {
    return requestSingle({
        url: `/mini/server/meter/pay/multi`,
        method: 'post',
        data
    })
}

